<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <!--userinfo的uId放入隐藏域-->
        <input type="hidden" th:value="${staff.staffId}" name="staffId" id="staffId" >

        <div class="layui-form-item">
            <label for="staffName" class="layui-form-label">
                <span class="x-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text" th:value="${staff.staffName}" id="staffName" name="staffName"  lay-verify="readonly"
                       autocomplete="off" class="layui-input" readonly="readonly">
            </div>
            <div class="layui-form-item">
                <label for="staffUsername" class="layui-form-label">
                    <span class="x-red">*</span>账号
                </label>
                <div class="layui-input-inline">
                    <input type="text" th:value="${staff.staffUsername}" id="staffUsername" name="staffUsername"  lay-verify="readonly"
                           autocomplete="off" class="layui-input" readonly="readonly">
                </div><div class="layui-form-item">
                <label for="role" class="layui-form-label">
                    <span class="x-red">*</span>当前身份
                </label>
                <div class="layui-input-inline">
                    <input type="text" th:each="r:${staff.roleList} " th:value="${r.roleName}" id="role" name="role"  lay-verify="readonly"
                           autocomplete="off" class="layui-input" readonly="readonly">
                </div>
            <div class="layui-form-item">
                <label for="roleName" class="layui-form-label">
                    <span class="x-red">*</span>权限
                </label>
                <div class="layui-input-inline">
<!--                    <input type="text"  id="roleName" name="roleName"  lay-verify="readonly"-->
<!--                           autocomplete="off" class="layui-input">-->
                    <select  id="roleId" onchange="selectrole()">
                        <option>---请选择---</option>
                        <option value="1">超级管理员</option>
                        <option value="2">管理员</option>
                        <option value="3">员工</option>
                    </select>
                </div>
            </div>
        <button  class="layui-btn" lay-filter="save" lay-submit="">
            保存
        </button>

    </form>
</div>
</div>
</body>
</html>
<script>

    //form表单,layer弹出框
    layui.use(['form','layer'],function () {
        $ = layui.jquery;
        var form = layui.form,layer = layui.layer;

        //保存按钮
        form.on('submit(save)',function () {
                var staffId = $("#staffId").val();
                var roleId = $("#roleId").val();
                $.ajax({
                url:"/role/submitEdit",
                type:"POST",
                dataType:"json",
                data:{"staffId":staffId,
                    "roleId":roleId,

                },
                success:function (data){
                    //提示信息
                    layer.alert(data.info);
                    //放入了map中，调用info
                    if (data.info=="修改成功"){
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        //刷新
                        parent.window.location.replace("/role/list")
                    }
                }

            })

            return false;
        });
    });

    //

</script>